//
//  RobotType.h
//  symbrion
//
//  Created by Berend Weel on 4/2/13.
//  Copyright (c) 2013 Berend Weel. All rights reserved.
//

#ifndef symbrion_RobotType_h
#define symbrion_RobotType_h

#include <webots/Robot.hpp>
#include "constants.h"

using namespace webots;

class RobotType : public Robot {
public:
    virtual size_t getNumConnectors() = 0;
    virtual bool hasConnector(size_t index) = 0;
    virtual Connector* getConnector(size_t connector) = 0;
    
    virtual size_t getNumDistanceSensors() = 0;
    virtual bool hasDistanceSensor(size_t index) = 0;
    virtual double getDistanceSensorValue(size_t index) = 0;
    
    virtual Servo* getMainHinge() = 0;
    
    virtual size_t getNumIRReceivers() = 0;
    virtual bool hasIRReceiver(size_t index) = 0;
    virtual Receiver* getIRReceiver(size_t index) = 0;
    
    virtual size_t getNumIREmitters() = 0;
    virtual bool hasIREmitter(size_t index) = 0;
    virtual Emitter* getIREmitter(size_t index) = 0;
    
    virtual size_t getNumLEDs() = 0;
    virtual bool hasLED(size_t index) = 0;
    virtual LED* getLED(size_t index) = 0;
    
    virtual void setLeftSpeed(double speed) = 0;
    virtual void setRightSpeed(double speed) = 0;
    
    virtual void initialiseHardware(){
        gps = getGPS("gps");
        
        eggreceiver = getReceiver("eggreceiver");
        eggemitter = getEmitter("eggradio");
        
        organismreceiver = getReceiver("organismreceiver");
        organismemitter = getEmitter("organismemitter");
        
        radioreceiver = getReceiver("radioreceiver");
        radioemitter = getEmitter("radioemitter");
        
        eggreceiver->enable(TIMESTEP);
        radioreceiver->enable(TIMESTEP);
        organismreceiver->enable(TIMESTEP);
        gps->enable(TIMESTEP);
    }
    
    Emitter* getOrganismEmitter() {
        return organismemitter;
    }
    
    Receiver* getOrganismReceiver() {
        return organismreceiver;
    }

	Emitter* getEggEmitter() const {
		return eggemitter;
	}

	Receiver* getEggReceiver() const {
		return eggreceiver;
	}

	GPS* getGps() const {
		return gps;
	}

	Emitter* getRadioEmitter() const {
		return radioemitter;
	}

	Receiver* getRadioReceiver() const {
		return radioreceiver;
	}

private:
    GPS *gps;
    
    Receiver *eggreceiver;
    Emitter *eggemitter;
    Receiver *organismreceiver;
    Emitter *organismemitter;
    Receiver *radioreceiver;
    Emitter *radioemitter;
};

#endif
